<template>
  <div class="d_mainFlex">
    <div class="d_treeBox p10">
      <el-form
        ref="materForm"
        :model="form"
        :rules="rules"
        hide-required-asterisk
        label-width="auto"
        class="dialogForm dialogInlineForm"
        label-position="top"
      >
        <el-row>
          <el-col>
            <el-form-item label="操作人员">
              <div class="flex">
                <el-input
                  v-model="name"
                  size="small"
                  placeholder="输入工号或扫码"
                  disabled
                />
                <el-button
                  size="small"
                  type="primary"
                  style="margin-left: 5px; min-width: 70px"
                  @click="loginModel = true"
                  >切换</el-button
                >
              </div>
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="生产单号" prop="produceTaskBillNo">
              <el-input
                v-model="form.produceTaskBillNo"
                size="small"
                ref="produceTaskBillNo"
                @keyup.enter.native="handleSave"
                placeholder="输入生产单号或扫码"
              />
            </el-form-item>
          </el-col>
          <!-- <el-col>
            <el-form-item label="机台工艺" prop="deviceCraftCode">
              <el-input
                v-model="form.deviceCraftCode"
                size="small"
                ref="device"
                @keyup.enter.native="handleSave"
                placeholder="输入工艺编码或扫码"
              />
            </el-form-item>
          </el-col> -->
          <el-col>
            <el-button
              type="primary"
              size="small"
              style="width: 100%; margin-top: 10px"
              @click.native.prevent="handleSave"
              >确定</el-button
            >
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="d_main">
      <div class="d_operationBox">
        <div></div>
        <div class="d_search">
          <screec
            v-model="search.QueryDataBaseFiled"
            :headData.sync="tableHead"
            :disabled="searchLoading"
          ></screec>
          <el-input
            v-model="search.likeWords"
            placeholder="请输入关键字"
            size="small"
            @keyup.enter.native="getAllMaterils"
          >
            <el-button
              slot="append"
              :loading="searchLoading"
              type="primary"
              icon="el-icon-search"
              :disabled="searchLoading"
              element-loading-spinner="el-icon-loading"
              @click="getAllMaterils"
            >
              搜索
            </el-button>
          </el-input>
        </div>
      </div>
      <!-- 操作区 E-->
      <!-- 表格操作区 S-->
      <div class="d_tableOperation">
        <div class="d_condition"></div>
        <div class="d_set">
          <el-checkbox
            v-model="search.isDisabled"
            @change="handleisDisabledChange"
            >显示作废</el-checkbox
          >
          <div @click="Refresh"><i class="d_icon el-icon-refresh-right" /></div>
          <div class="setting flex">
            <HeadSeting
              :list-data.sync="tableHead"
              :table-code="$config.ScanningWorkTabel"
              @reset="getTableHead"
            />
          </div>
        </div>
      </div>
      <!-- 表格操作区 E-->
      <!--table板块-->
      <div ref="tableCon" class="tableCon expandBox">
        <el-table
          v-show="tableHead.length > 0"
          id="emtable"
          ref="multipleTable"
          v-loading="searchLoading"
          :data="dataLists"
          :height="tableHeight || 'auto'"
          border
          fit
          style="width: 100%"
          @header-dragend="surverWidth"
        >
          <template v-for="(fruit, index) in tableHead">
            <el-table-column
              v-if="fruit.visible"
              :key="index"
              :label="fruit.columnName"
              :min-width="fruit.columnWidth || 90"
              :prop="fruit.columnCode"
              show-overflow-tooltip
              :fixed="fruit.isFloat ? 'left' : false"
            >
              <template slot-scope="scope">
                <div v-if="fruit.columnCode === 'craftWorkState'">
                  <div v-if="scope.row.craftWorkState == 0">
                    <el-tag size="small">作业中</el-tag>
                  </div>
                  <div v-else-if="scope.row.craftWorkState == 1">
                    <el-tag size="small" type="success">已完成</el-tag>
                  </div>
                  <div v-else>
                    <el-tag size="small" type="danger">已停工</el-tag>
                  </div>
                </div>
                <div v-else-if="fruit.columnCode === 'isDisabled'">
                  <div>{{ scope.row.isDisabled ? "是" : "否" }}</div>
                </div>
                <div v-else>
                  {{ scope.row[fruit.columnCode] }}
                </div>
              </template>
            </el-table-column>
          </template>
          <el-table-column
            label="操作"
            width="70px"
            fixed="right"
            align="center"
          >
            <template slot-scope="scope">
              <div>
                <el-popover
                  :ref="`popover-${scope.$index}`"
                  placement="bottom-end"
                  popper-class="tableOp"
                  width="160"
                  :popper-options="{
                    boundariesElement: 'opBox',
                    removeOnDestroy: true,
                  }"
                  trigger="click"
                >
                  <div class="operation">
                    <ul>
                      <li @click="handleSeeClick(scope.row)">查看</li>
                      <li @click="handleUpdata(scope.row)">修改</li>
                    </ul>
                    <ul>
                      <li
                        v-if="scope.row.craftWorkState == 0"
                        @click="doneWork(scope.row)"
                      >
                        完成
                      </li>
                      <li
                        v-if="scope.row.isDisabled == 0"
                        @click="handleDone(scope.row)"
                      >
                        作废
                      </li>
                    </ul>
                  </div>
                  <div slot="reference" class="opBox pointer">
                    <span class="el-icon-more c_3F61F1" />
                  </div>
                </el-popover>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <!-- 骨架屏     -->
        <div v-if="tableHead.length == 0" class="p16">
          <el-skeleton :rows="6" animated />
        </div>
      </div>
      <!-- 分页 S-->
      <div class="d_pag">
        <pagination
          :total="total || 0"
          :page.sync="search.pageIndex"
          :limit.sync="search.pageSize"
          @pagination="getAllMaterils"
        />
      </div>
    </div>

    <!-- 切换账号 -->
    <el-dialog
      title="快速登录"
      :visible.sync="loginModel"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog "
      width="25%"
    >
      <div class="p16 pt0">
        <el-form
          ref="loginForm"
          :model="loginForm"
          :rules="loginRules"
          hide-required-asterisk
          label-width="auto"
          class="dialogForm dialogInlineForm"
          label-position="top"
        >
          <el-row>
            <el-col>
              <el-form-item label="登录账号" prop="loginAccount">
                <el-input
                  v-model="loginForm.loginAccount"
                  size="small"
                  placeholder="输入登录账号"
                />
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="登录密码" prop="loginPassWord">
                <el-input
                  v-model="loginForm.loginPassWord"
                  size="small"
                  placeholder="输入登录密码"
                />
              </el-form-item>
            </el-col>
            <el-col>
              <el-button
                type="primary"
                size="small"
                style="width: 100%; margin-top: 10px"
                @click.native.prevent="handleLogin"
                >确认登录</el-button
              >
            </el-col>
          </el-row>
        </el-form>
      </div>
    </el-dialog>

    <!-- 生产工艺列表 -->
    <el-dialog
      title="选择生产工艺"
      :visible.sync="workmanshipModel"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog bigDialogh85"
      width="85%"
    >
      <div class="list list_3 p16">
        <div
          class="list-item"
          :class="[
            {
              finish: item.craftTaskState == 2,
              conduct: item.craftTaskState == 1 || item.craftTaskState == 3,
            },
          ]"
          v-for="(item, index) in workmanshipList"
          :key="index"
          @click="handleItem(item, index)"
        >
          <div class="head-info">
            <div>
              <span>工序：{{ item.produceCraftSort }}</span>
              <span class="ml16"
                >计划用时：{{ item.craftTaskPlanUseTime }}分钟</span
              >
            </div>
            <div>
              <span v-if="item.craftTaskState == 0">状态：待开始</span>
              <span v-else-if="item.craftTaskState == 1">状态：进行中</span>
              <span v-else-if="item.craftTaskState == 2">状态：已完成</span>
              <span v-else-if="item.craftTaskState == 3">状态：流转</span>
            </div>
          </div>
          <div class="item-content">
            <h1>{{ item.craftName }}</h1>
            <p>{{ item.machineName }}</p>
          </div>
        </div>
        <el-empty
          :image-size="200"
          v-if="workmanshipList.length < 1"
          style="margin: 150px auto"
          description="暂无工艺"
        ></el-empty>
      </div>
    </el-dialog>

    <!-- 完成机台作业   -->
    <el-dialog
      :title="Matitle"
      :visible.sync="showAddDialog"
      :close-on-click-modal="false"
      custom-class="bodyNoPadDialog bigDialog bigDialogh85"
      width="85%"
    >
      <div class="dialogDody">
        <div class="subTipBtn">
          <span class="mr15"
            ><span class="mr5">作业单号：</span
            >{{ machiaForm.workTaskNo || "系统自动生成" }}</span
          >
          <span class="mr15"
            ><span class="mr5">创建日期：</span
            >{{
              machiaForm.workBeginTime || dayjs().format("YYYY-MM-DD")
            }}</span
          >
          <span
            ><span class="mr5">创建人员：</span
            >{{ machiaForm.workPersonName }}</span
          >
        </div>
        <el-form
          ref="machiaForm"
          :model="machiaForm"
          :rules="rulesFrom"
          class="dialogForm h100"
          label-width="80px"
        >
          <el-row class="h100">
            <el-col :span="18" class="fleft h100">
              <el-row>
                <el-col :span="8"
                  ><el-form-item label="订单单号" prop="xieYiShuHao">
                    <el-input
                      v-model="machiaForm.xieYiShuHao"
                      size="mini"
                      disabled /></el-form-item
                ></el-col>
                <el-col :span="8"
                  ><el-form-item label="生产单号" prop="produceTaskBillNo">
                    <el-input
                      v-model="machiaForm.produceTaskBillNo"
                      size="mini"
                      disabled /></el-form-item
                ></el-col>
                <el-col :span="8"
                  ><el-form-item label="作业单号" prop="workTaskNo">
                    <el-input
                      v-model="machiaForm.workTaskNo"
                      size="mini"
                      disabled /></el-form-item
                ></el-col>
              </el-row>
              <el-row>
                <el-col :span="8"
                  ><el-form-item label="产品名称" prop="orderProductName">
                    <el-input
                      v-model="machiaForm.orderProductName"
                      size="mini"
                      disabled /></el-form-item
                ></el-col>
                <el-col :span="8"
                  ><el-form-item label="工艺名称" prop="produceCraftName">
                    <el-input
                      v-model="machiaForm.produceCraftName"
                      size="mini"
                      disabled
                    /> </el-form-item
                ></el-col>
                <el-col :span="8"
                  ><el-form-item label="操作人员" prop="workPersonName">
                    <el-input
                      v-model="machiaForm.workPersonName"
                      size="mini"
                      disabled
                    /> </el-form-item
                ></el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="机台名称" prop="produceMachineName">
                    <el-input
                      v-model="machiaForm.produceMachineName"
                      size="mini"
                      disabled
                    /> </el-form-item
                ></el-col>
                <el-col :span="8">
                  <el-form-item label="生产设备" prop="equipmentCode">
                    <el-select
                        filterable
                      v-model="machiaForm.equipmentCode"
                      size="mini"
                      placeholder="请选择生产设备"
                      :disabled="allcanDisablle || equipment.length < 1"
                    >
                      <el-option
                        v-for="item in equipment"
                        :key="item.equipmentNo"
                        :label="item.equipmentName"
                        :value="item.equipmentNo"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="副手人员" prop="assistantList">
                    <div class="flex permain">
                      <div class="input">
                        <span
                          v-for="(v, p) in assisList"
                          :key="v.employeeCode"
                          class="pointer"
                          @click="deletrPer(p) && allcanDisablle"
                        >
                          {{ v.employeeName }}<i class="el-icon-close" />
                        </span>
                      </div>
                      <el-button
                        class="bgc57"
                        size="mini"
                        icon="el-icon-user"
                        @click="openPer"
                      />
                    </div>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="工艺状态" prop="craftState">
                    <el-select
                        filterable
                      v-model="machiaForm.craftState"
                      size="mini"
                      placeholder="请选择工艺状态"
                    >
                      <el-option label="生产中" :value="1"></el-option>
                      <el-option label="已完成" :value="2"></el-option>
                      <el-option label="流转" :value="3"></el-option>
                    </el-select> </el-form-item
                ></el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="作业备注" prop="workTaskRemark">
                    <el-input
                      v-model="machiaForm.workTaskRemark"
                      type="textarea"
                      :rows="3"
                      size="mini"
                      :disabled="allcanDisablle"
                    /> </el-form-item
                ></el-col>
              </el-row>
              <template v-if="type == '印刷'">
                <el-row>
                  <div class="cTitle">
                    <h3>作业信息</h3>
                  </div>
                  <el-col :span="8"
                    ><el-form-item label="计划米数" prop="planMeters">
                      <el-input
                        v-model="machiaForm.planMeters"
                        disabled
                        size="mini"
                      >
                        <template slot="append">米</template></el-input
                      >
                    </el-form-item></el-col
                  >

                  <el-col :span="8"
                    ><el-form-item label="生产米数" prop="produceMeters">
                      <el-input
                        v-model="machiaForm.produceMeters"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        size="mini"
                        @blur="efficiency"
                        :disabled="allcanDisablle"
                      >
                        <template slot="append">米</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                        size="mini"
                        :disabled="allcanDisablle"
                        @blur="productMeter"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <div class="cTitle">
                  <h3>主料明细</h3>
                </div>
                <el-table
                  :data="machiaForm.mainMaterialDataList"
                  border
                  style="width: 100%"
                  height="200px"
                >
                  <el-table-column
                    prop="stockGoodsCode"
                    label="物料编号"
                    width="100"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="goodsName"
                    label="物料名称"
                    width="110"
                  >
                  </el-table-column>
                  <el-table-column prop="stockGoodsName" label="规格型号">
                  </el-table-column>
                  <el-table-column prop="planUseQuantity" label="计划用料">
                  </el-table-column>
                  <el-table-column prop="printUseQuantity" label="打印用料">
                  </el-table-column>
                  <el-table-column prop="produceGetQuantity" label="领料数量">
                  </el-table-column>
                  <el-table-column prop="replenishQuantity" label="补料数量">
                  </el-table-column>
                  <el-table-column
                    prop="usedSumQuantity"
                    label="已使用数量"
                    width="100"
                  >
                  </el-table-column>
                  <el-table-column prop="goodsUnitName" label="单位">
                  </el-table-column>
                  <el-table-column prop="usedQuantity" label="使用数量">
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.usedQuantity"
                        placeholder="请输入"
                        size="mini"
                        type="number"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
                <div class="cTitle">
                  <h3>辅料明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="showMateria = true"
                      ><i class="el-icon-circle-plus-outline"></i>选择物料</span
                    >|<span @click="handleDeleteMaterial"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>
                <el-table
                  :data="machiaForm.ingredientsDataList"
                  @selection-change="handleMaterialChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column prop="stockGoodsCode" label="物料编号">
                  </el-table-column>
                  <el-table-column prop="goodsName" label="物料名称">
                  </el-table-column>
                  <el-table-column prop="goodsUnitName" label="单位">
                  </el-table-column>
                  <el-table-column prop="usedQuantity" label="使用数量">
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.usedQuantity"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>

              <!-- 制版 -->
              <!-- <el-row>
              <div class="cTitle">
                <h3>申请信息</h3>
              </div>
                <el-col :span="8"
                  ><el-form-item label="申请单号" prop="productMeter">
                    <el-input
                      v-model="machiaForm.productMeters"
                      disabled
                      size="mini"
                    >
                     </el-input
                    >
                  </el-form-item></el-col
                >

                <el-col :span="8"
                  ><el-form-item label="版数" prop="finishedMeters">
                    <el-input
                      v-model="machiaForm.produceMeters"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
                <el-col :span="8"
                  ><el-form-item label="efficiency" prop="finishedRollCount">
                    <el-input
                      v-model="machiaForm.finishedRollCount"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
              </el-row>
              <el-row>
                <el-col :span="8"
                  ><el-form-item label="申请机台" prop="finishedMeters">
                    <el-input
                      v-model="machiaForm.produceMeters"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
                <el-col :span="8"
                  ><el-form-item label="申请人员" prop="finishedMeters">
                    <el-input
                      v-model="machiaForm.produceMeters"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
              </el-row>
              <div class="cTitle">
                <h3>作业信息</h3>
              </div>
              <el-row>
                <el-col :span="8"
                  ><el-form-item label="刀版编号" prop="productMeter">
                    <el-input
                      v-model="machiaForm.productMeters"
                      size="mini"
                      placeholder="请填写刀版编号"
                      :disabled="allcanDisablle"
                    >
                     </el-input
                    >
                  </el-form-item></el-col
                >

                <el-col :span="8"
                  ><el-form-item label="刀版名称" prop="finishedMeters">
                    <el-input
                      v-model="machiaForm.produceMeters"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      placeholder="请填写刀版名称"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
                <el-col :span="8"
                  ><el-form-item label="刀版尺寸" prop="finishedRollCount">
                    <el-input
                      v-model="machiaForm.finishedRollCount"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      placeholder="请填写刀版尺寸"
                      :disabled="allcanDisablle"
                    >
                      <template slot="append">mm</template></el-input
                    >
                  </el-form-item></el-col
                >
              </el-row>
              <el-row>
                <el-col :span="8"
                  ><el-form-item label="模数" prop="productMeter">
                    <el-input
                      v-model="machiaForm.productMeters"
                      disabled
                      size="mini"
                      placeholder="请填写模数"
                    >
                     </el-input
                    >
                  </el-form-item></el-col
                >

                <el-col :span="8"
                  ><el-form-item label="刀版费用" prop="finishedMeters">
                    <el-input
                      v-model="machiaForm.produceMeters"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      placeholder="请填写刀版费用"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
                <el-col :span="8"
                  ><el-form-item label="存放位置" prop="finishedRollCount">
                    <el-input
                      v-model="machiaForm.finishedRollCount"
                      onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                      size="mini"
                      placeholder="请填写存放位置"
                      :disabled="allcanDisablle"
                    >
                    </el-input
                    >
                  </el-form-item></el-col
                >
              </el-row>
              <el-row>
                <el-col :span="24"
                  ><el-form-item label="制版尺寸" prop="productMeter">
                    <el-input
                      v-model="machiaForm.productMeters"
                      size="mini"
                      :disabled="allcanDisablle"
                      placeholder="尺寸多个用逗号分开，如(小标，中标，大标)"
                    >
                     </el-input
                    >
                  </el-form-item></el-col
                >
              </el-row>
              <el-row>
                <el-col :span="24"
                  ><el-form-item label="刀版备注" prop="productMeter">
                    <el-input
                      v-model="machiaForm.productMeters"
                      size="mini"
                      type="textarea"
                      :disabled="allcanDisablle"
                      :rows="3"
                      placeholder="请填写刀版备注"
                    >
                     </el-input
                    >
                  </el-form-item></el-col
                >
              </el-row> -->

              <template v-if="type == '丝网'">
                <div class="cTitle">
                  <h3>作业明细</h3>
                </div>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        placeholder="请填写完成卷数"
                        :disabled="allcanDisablle"
                        size="mini"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="印面" prop="printFace">
                      <el-input
                        v-model="machiaForm.printFace"
                        placeholder="请填写印面"
                        :disabled="allcanDisablle"
                        size="mini"
                        @blur="calculation"
                      >
                        <template slot="append">mm</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="次数" prop="printCount">
                      <el-input
                        v-model="machiaForm.printCount"
                        placeholder="请填写次数"
                        :disabled="allcanDisablle"
                        @blur="calculation"
                        size="mini"
                      >
                        <template slot="append">次</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="成品米数" prop="sW_ProductMeters">
                      <el-input
                        v-model="machiaForm.sW_ProductMeters"
                        placeholder="请填写次数"
                        disabled
                        size="mini"
                      >
                        <template slot="append">米</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <div class="cTitle">
                  <h3>辅料明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="showMateria = true"
                      ><i class="el-icon-circle-plus-outline"></i>选择物料</span
                    >|<span @click="handleDeleteMaterial"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>
                <el-table
                  :data="machiaForm.ingredientsDataList"
                  @selection-change="handleMaterialChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column prop="goodsCode" label="物料编号">
                  </el-table-column>
                  <el-table-column prop="goodsName" label="物料名称">
                  </el-table-column>
                  <el-table-column prop="stockGoodsName" label="规格型号">
                  </el-table-column>
                  <el-table-column prop="goodsUnitName" label="单位">
                  </el-table-column>
                  <el-table-column prop="usedQuantity" label="使用数量">
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.usedQuantity"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>

                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>

              <template v-if="type == '模切'">
                <!-- <div class="cTitle">
                  <h3>作业明细</h3>
                </div>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        placeholder="请填写完成卷数"
                        :disabled="allcanDisablle"
                        size="mini"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="刀版尺寸" prop="knifeVersionSize">
                      <el-input
                        v-model="machiaForm.knifeVersionSize"
                        placeholder="请填写刀版尺寸"
                        :disabled="allcanDisablle"
                        size="mini"
                        @blur="calculation"
                      >
                        <template slot="append">mm</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="模切次数" prop="cutCount">
                      <el-input
                        v-model="machiaForm.cutCount"
                        placeholder="请填写模切次数"
                        :disabled="allcanDisablle"
                        @blur="calculation"
                        size="mini"
                      >
                        <template slot="append">次</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="成品米数" prop="mQ_ProductMeters">
                      <el-input
                        v-model="machiaForm.mQ_ProductMeters"
                        placeholder="请填写次数"
                        disabled
                        size="mini"
                      >
                        <template slot="append">米</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row> -->

                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template v-if="type == '数码'">
                <div class="cTitle">
                  <h3>作业明细</h3>
                </div>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        placeholder="请填写完成卷数"
                        :disabled="allcanDisablle"
                        size="mini"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="打印页数" prop="printPageCount">
                      <el-input
                        v-model="machiaForm.printPageCount"
                        placeholder="请填写打印页数"
                        :disabled="allcanDisablle"
                        size="mini"
                        @blur="calculation"
                      >
                        <template slot="append">页</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="页面大小" prop="printPageSize">
                      <el-input
                        v-model="machiaForm.printPageSize"
                        placeholder="请填写页面大小"
                        :disabled="allcanDisablle"
                        @blur="calculation"
                        size="mini"
                      >
                        <template slot="append">mm</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="成品米数" prop="sM_ProductMeters">
                      <el-input
                        v-model="machiaForm.sM_ProductMeters"
                        placeholder="请填写次数"
                        disabled
                        size="mini"
                      >
                        <template slot="append">米</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>

                <div class="cTitle">
                  <h3>页码明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="handleAddPage"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeletePage"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>
                <el-table
                  :data="machiaForm.pageDetailDataList"
                  @selection-change="handlePageChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="文件名称"
                    prop="pageFileName"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.pageFileName"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="总页数"
                    prop="totalPageCount"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.totalPageCount"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="起始号"
                    prop="beginNo"
                    show-overflow-tooltip
                    width="120"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="截止号"
                    prop="endNo"
                    show-overflow-tooltip
                    width="120"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="remark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.remark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>

                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template v-if="type == '采集'">
                <div class="cTitle">
                  <h3>作业明细</h3>
                </div>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        placeholder="请填写完成卷数"
                        :disabled="allcanDisablle"
                        size="mini"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="每卷数量" prop="everyRollQuantity">
                      <el-input
                        v-model="machiaForm.everyRollQuantity"
                        placeholder="请填写每卷数量"
                        :disabled="allcanDisablle"
                        size="mini"
                        @blur="calculation"
                      >
                        <template slot="append">{{
                          machiaForm.orderProductUnit
                        }}</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="成品数量" prop="productQuantity">
                      <el-input
                        v-model="machiaForm.productQuantity"
                        placeholder="请填写成品数量"
                        :disabled="allcanDisablle"
                        @blur="efficiency"
                        size="mini"
                      >
                        <template slot="append">{{
                          machiaForm.orderProductUnit
                        }}</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template v-if="type == '检验'">
                <div class="cTitle">
                  <h3>作业明细</h3>
                </div>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="完成卷数" prop="finishedRollCount">
                      <el-input
                        v-model="machiaForm.finishedRollCount"
                        placeholder="请填写完成卷数"
                        :disabled="allcanDisablle"
                        size="mini"
                      >
                        <template slot="append">卷</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="检验米数" prop="inspectMeters">
                      <el-input
                        v-model="machiaForm.inspectMeters"
                        placeholder="请填写检验米数"
                        :disabled="allcanDisablle"
                        @blur="efficiency"
                        size="mini"
                      >
                        <template slot="append">{{
                          machiaForm.orderProductUnit
                        }}</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="检验数量" prop="inspectCount">
                      <el-input
                        v-model="machiaForm.inspectCount"
                        placeholder="请填写检验数量"
                        :disabled="allcanDisablle"
                        @blur="calculation"
                        size="mini"
                      >
                        <template slot="append">{{
                          machiaForm.orderProductUnit
                        }}</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <el-row>
                  <el-col :span="8"
                    ><el-form-item label="不良成品" prop="noPassCount">
                      <el-input
                        v-model="machiaForm.noPassCount"
                        placeholder="请填写不良成品"
                        :disabled="allcanDisablle"
                        @blur="calculation"
                        size="mini"
                      >
                        <template slot="append">套</template></el-input
                      >
                    </el-form-item></el-col
                  >
                  <el-col :span="8"
                    ><el-form-item label="不合格率" prop="percentDefective">
                      <el-input
                        v-model="machiaForm.percentDefective"
                        placeholder="自动计算"
                        disabled
                        size="mini"
                      >
                        <template slot="append">%</template></el-input
                      >
                    </el-form-item></el-col
                  >
                </el-row>
                <div class="cTitle">
                  <h3>异常明细</h3>
                  <div class="operations" v-if="!allcanDisablle">
                    <span @click="addExecp"
                      ><i class="el-icon-circle-plus-outline"></i>添加明细</span
                    >|<span @click="handleDeleteAbnormal"
                      ><i class="el-icon-delete"></i>删除</span
                    >
                  </div>
                </div>

                <el-table
                  :data="machiaForm.exceptionDataList"
                  @selection-change="handleAbnormalChange"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    label="卷号"
                    prop="reelNumber"
                    show-overflow-tooltip
                    width="190"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.reelNumber"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="开始页码"
                    prop="beginPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.beginPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="结束页码"
                    prop="endPageNo"
                    show-overflow-tooltip
                    width="100"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.endPageNo"
                        placeholder="请输入"
                        type="number"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="异常原因"
                    prop="exceptionReason"
                    show-overflow-tooltip
                    width="230"
                  >
                    <template slot-scope="{ row }">
                      <el-select
                        filterable
                        v-model="row.exceptionReason"
                        placeholder="请选择"
                        multiple
                        filterable
                        size="mini"
                        :disabled="allcanDisablle"
                      >
                        <el-option
                          v-for="item in reasonDataList"
                          :key="item.exceptionCode"
                          :label="item.exceptionName"
                          :value="item.exceptionCode"
                        />
                      </el-select>
                    </template>
                  </el-table-column>

                  <el-table-column
                    label="备注"
                    show-overflow-tooltip
                    min-width="150"
                    prop="exceptionRemark"
                  >
                    <template slot-scope="{ row }">
                      <el-input
                        v-model="row.exceptionRemark"
                        placeholder="请输入"
                        size="mini"
                        :disabled="allcanDisablle"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </el-col>
            <el-col :span="6" class="formItem fright">
              <el-form-item label="上班班次" prop="indexNumber">
                <el-select
                        filterable
                  v-model="machiaForm.workShiftNo"
                  :disabled="allcanDisablle"
                  placeholder="请选择"
                  size="mini"
                  filterable
                >
                  <el-option
                    v-for="item in bcList"
                    :key="item.code"
                    :label="item.name"
                    :value="item.code"
                  />
                </el-select>
              </el-form-item>
              <el-form-item label="开始时间">
                <el-date-picker
                  v-model="machiaForm.workBeginTime"
                  type="datetime"
                  :picker-options="option"
                  placeholder="选择日期"
                  size="mini"
                  disabled
                />
              </el-form-item>
              <el-form-item label="结束时间">
                <el-date-picker
                  v-model="machiaForm.workFinishTime"
                  type="datetime"
                  :picker-options="option"
                  placeholder="选择日期"
                  size="mini"
                  disabled
                />
              </el-form-item>
              <el-form-item label="产品耗时">
                <el-input
                  v-model="machiaForm.taskUseTime"
                  onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                  placeholder="0"
                  size="mini"
                  disabled
                >
                  <template slot="append">分钟</template></el-input
                >
              </el-form-item>
              <el-form-item label="其他时间">
                <el-input
                  v-model="machiaForm.otherUseTime"
                  placeholder="0"
                  size="mini"
                  :disabled="allcanDisablle"
                  @blur="efficiency"
                >
                  <template slot="append">分钟</template></el-input
                >
              </el-form-item>
              <el-form-item label="计划工时">
                <el-input
                  v-model="machiaForm.planWorkTime"
                  onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                  placeholder="0"
                  size="mini"
                  disabled
                >
                  <template slot="append">分钟</template></el-input
                >
              </el-form-item>

              <el-form-item label="标准效率">
                <el-input
                  v-model="machiaForm.standardEfficiency"
                  onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                  placeholder="0"
                  size="mini"
                  disabled
                >
                  <template slot="append">米/小时</template></el-input
                >
              </el-form-item>
              <el-form-item label="生产工时">
                <el-input
                  v-model="machiaForm.actualWorkTime"
                  onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                  placeholder="0"
                  size="mini"
                  disabled
                >
                  <template slot="append">分钟</template></el-input
                >
              </el-form-item>
              <el-form-item label="工作效率">
                <el-input
                  v-model="machiaForm.workEfficiency"
                  onkeyup="this.value = this.value.replace(/[^\d.]/g,'');"
                  placeholder="0"
                  size="mini"
                  disabled
                >
                  <template slot="append" v-if="type == '采集'">枚/套</template>
                  <template slot="append" v-else>米/小时</template></el-input
                >
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="showAddDialog = false">取 消</el-button>
        <!-- 新增       -->
        <el-button
          v-if="opsid !== -1"
          :loading="addLoading"
          :disabled="addLoading"
          element-loading-spinner="el-icon-loading"
          type="primary"
          size="mini"
          @click="saveMachina"
        >
          {{ opsid === 0 ? "完成" : "保存" }}</el-button
        >
      </div>
    </el-dialog>
    <!-- 人员寻找弹框   -->
    <per-redio-dialog
      :per-visible.sync="isperShow"
      @getEmployee="getEmployee"
    />

    <!--   选择物料  -->
    <SelectMateriaList
      ref="materiaList"
      :per-visible.sync="showMateria"
      @getMateriListData="refuseListsMateriAll"
    />
  </div>
</template>
<script>
import { arraySort } from "@/utils";
import HeadSeting from "@/components/HeadSeting";
import Pagination from "@/components/Pagination";
import perRedioDialog from "@/components/perDialogRedio";
import SelectMateriaList from "@/components/selectMaterial";
import pinyin from "js-pinyin";
import { mapGetters } from "vuex";
import screec from "@/components/screen";
import picking from "./components/picking";
import returnMaterial from "./components/returnMaterial";

export default {
  name: "Materiel",
  components: {
    Pagination,
    HeadSeting,
    screec,
    picking,
    returnMaterial,
    perRedioDialog,
    SelectMateriaList,
  },
  computed: {
    ...mapGetters(["name"]),
  },
  data() {
    const validatePassword = (rule, value, callback) => {
      if (value.length < 6) {
        callback(new Error("密码长度不正确"));
      } else {
        callback();
      }
    };
    return {
      form: {
        produceTaskBillNo: "", //订单编号
        deviceCraftCode: "", //机台工艺编号
      },

      loginForm: {
        loginAccount: "", //账号
        loginPassWord: "", //密码
      },

      loginRules: {
        loginAccount: [
          { required: true, trigger: "blur", message: "请输入账号" },
        ],
        loginPassWord: [
          { required: true, trigger: "blur", validator: validatePassword },
        ],
      },

      search: {
        pageIndex: 1,
        pageSize: 30,
        likeWords: "",
        QueryDataBaseFiled: "",
        employeeCode: "",
        isDisabled: false,
      },

      total: 0,
      dataLists: [],
      tableHead: [],
      tableHeight: null, // 表格最大高度
      tableScreenHead: [],
      bcList: [],
      workmanshipList: [], //工艺列表数据
      workmanshipModel: false, //生产工艺弹窗

      searchLoading: false,
      loginModel: false,

      isperShow: false,
      addLoading: false,
      rowID: 0,
      selectArr: [],
      showAddDialog: false,
      machiaForm: [],
      canDisablle: false,
      allcanDisablle: false,
      assisList: [],
      opsid: 0,
      ExceptionTypeList: [],
      isShadeShow: false,
      reasonVisibleall: false,
      addLableLoading: false,
      Matitle: "",
      showOrder: false, // 订单弹窗
      showCraft: false, // 选择工艺
      showMateria: false, // 选择物料
      showPicking: false, //生产领料
      showMaterial: false, //生产退料
      orderNo: "", // 订单号
      loading: null,
      conIndex: 0,
      tabsIndex: 0, // 右侧tabs切换索引
      tagIndex: 0, // 当前标签索引
      colorOps: "add", // 印刷颜色当前操作
      colorEditIndex: null, // 印刷颜色修改的索引
      dataLoading: false, // 订单详情数据加载
      orderLoading: false, // 订单保存加载效果
      isAddColor: false, // 印刷颜色新增弹框是否打开
      reasonDataList: [],
      materiaChecked: [], //辅料明细选中数据
      abnormalChecked: [], //异常明细选中数据
      pageChecked: [], //页码明细选中数据

      // 设置时间控件小于当前日期不能选择
      option: {
        disabledDate: (time) => {
          return time.getTime() < Date.now() - 1 * 24 * 3600 * 1000;
        },
      },
      selectDD: {},
      productFrom: {
        baseData: {},
        packageData: {},
        orderBaseData: {},
        productData: {},
      },
      isDisable: false, // 是否禁用输入框
      stopVisible: false,
      reasonVisible: false,
      typeStatus: 0,
      equipment: "",
      type: "",
      index: 0,
      indexPage: 0,
      productList: [],
      rulesFrom: {
        craftState: [
          { required: true, message: "请选择工艺状态", trigger: "change" },
        ],
      },
      rules: {
        produceTaskBillNo: [
          {
            required: true,
            message: "请输入生产单号",
            trigger: ["change", "blur"],
          },
        ],
        deviceCraftCode: [
          {
            required: true,
            message: "请输入机台工艺编码",
            trigger: ["change", "blur"],
          },
        ],
      },
    };
  },
  created() {
    // 基础数据表格得表头
    this.getTableHead();

    //获取班次
    this.getBC();

    this.getWorkExceptionTypeDataList();
  },
  mounted() {
    // 表格高度
    this.calHeight();
  },
  updated() {
    this.$nextTick(() => {
      this.$refs.multipleTable.doLayout();
    });
  },
  methods: {
    //登录
    handleLogin() {
      this.$refs.loginForm.validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$store
            .dispatch("user/login", this.loginForm)
            .then(() => {
              // this.$router.push({ path: '/scanning/code' })
              location.reload();
              // location.reload(true)
              this.loading = false;
            })
            .catch(() => {
              this.loading = false;
            });
        } else {
          return false;
        }
      });
    },

    //时间格式化
    dateFtt(fmt, date) {
      //author: meizz
      var o = {
        "M+": date.getMonth() + 1, //月份
        "d+": date.getDate(), //日
        "h+": date.getHours(), //小时
        "m+": date.getMinutes(), //分
        "s+": date.getSeconds(), //秒
        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
        S: date.getMilliseconds(), //毫秒
      };
      if (/(y+)/.test(fmt))
        fmt = fmt.replace(
          RegExp.$1,
          (date.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
      for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
          fmt = fmt.replace(
            RegExp.$1,
            RegExp.$1.length == 1
              ? o[k]
              : ("00" + o[k]).substr(("" + o[k]).length)
          );
      return fmt;
    },

    //点击显示作废
    handleisDisabledChange() {
      this.search.pageIndex = 1;
      this.getAllMaterils();
    },

    //点击列表工艺
    handleItem(row, index) {
      console.log(index);
      if (index > 0) {
        console.log(222);
        let previous = this.workmanshipList[index - 1].craftTaskState;
        if (previous == 2 || previous == 3 && row.craftTaskState != 2) {
          this.form.deviceCraftCode = row.machineCraftCode;
          this.$api.system
            .AddScanningWork(this.form)
            .then((res) => {
              this.$message.success("保存成功");
              this.form = {
                produceTaskBillNo: "", //订单编号
                deviceCraftCode: "", //机台工艺编号
              };
              this.getAllMaterils();
              this.workmanshipModel = false;
              this.$nextTick(() => {
                this.$refs["materForm"].clearValidate();
              });
            })
            .catch((err) => {
              this.form.deviceCraftCode = ""; //机台工艺编号
            });
        } else if (row.craftTaskState == 2) {
          this.$message.error("该工艺已完成，不可在建任务单");
          return;
        } else {
          this.$message.error("上一工序还没流转或已完成");
          return;
        }
      } else {
        if (row.craftTaskState == 2) {
          this.$message.error("该工艺已完成，不可在建任务单");
          return;
        } else {
          this.form.deviceCraftCode = row.machineCraftCode;
          this.$api.system
            .AddScanningWork(this.form)
            .then((res) => {
              this.$message.success("保存成功");
              this.form = {
                produceTaskBillNo: "", //订单编号
                deviceCraftCode: "", //机台工艺编号
              };
              this.$refs.materForm.clearValidate();
              this.getAllMaterils();
              this.workmanshipModel = false;
            })
            .catch((err) => {
              this.form.deviceCraftCode = ""; //机台工艺编号
            });
        }
      }
    },

    //点击确定
    handleSave() {
      this.$refs.materForm.validate((valid) => {
        if (valid) {
          this.$api.system
            .GetProduceCraftListByProduceTaskBillNo({
              produceTaskBillNo: this.form.produceTaskBillNo,
            })
            .then((res) => {
              this.workmanshipList = res;
              this.workmanshipModel = true;
            });
        }
      });
    },

    //保存生产作业
    saveMachina() {
      const _d = [];
      this.assisList.forEach((e) => {
        _d.push(e.employeeCode);
      });
      this.machiaForm.assistantList = _d;
      this.$refs.machiaForm.validate((valid) => {
        if(valid){
          if (this.opsid === 0) {
            this.$api.product
              .UpdateProduceCraftWorkTask(this.machiaForm)
              .then((res) => {
                this.$api.product
                  .FinishedProduceCraftWorkTask({ workTaskID: this.rowID })
                  .then((res) => {
                    this.getAllMaterils();
                    this.showAddDialog = false;
                    this.$message({
                      type: "success",
                      message: "完成成功!",
                    });
                  });
              });
          } else {
            this.machiaForm.exceptionDataList.forEach((item) => {
              item.beginPageNo = Number(item.beginPageNo);
              item.endPageNo = Number(item.endPageNo);
              item.exceptionReason = item.exceptionReason.join(",");
            });
            this.$api.product
              .UpdateProduceCraftWorkTask(this.machiaForm)
              .then((res) => {
                this.$message({
                  type: "success",
                  message: "修改成功!",
                });
                this.showAddDialog = false;
                this.getAllMaterils();
              });
          }
        }
      })
    },

    //查看生产作业
    handleSeeClick(row) {
      this.type = row.machineType;
      this.opsid = -1;
      this.Matitle = "查看生产作业";
      this.canDisablle = true;
      this.allcanDisablle = true;
      const _data = {
        workTaskID: row.workTaskID,
        workTaskNo: row.workTaskNo,
      };
      this.$api.product.GetProduceCraftWorkTaskDetail(_data).then((res) => {
        this.assisList = res.assistantList;
        this.machiaForm = res.baseData;
        this.machiaForm.exceptionDataList = res.exceptionDataList;
        this.machiaForm.mainMaterialDataList = res.mainMaterialDataList;
        this.machiaForm.ingredientsDataList = res.ingredientsDataList;
        this.machiaForm.pageDetailDataList = res.pageDetailDataList;
        this.reasonDataList = res.exceptionReasonList;
        this.machiaForm.produceUseTime = this.timeFn(
          this.machiaForm.workBeginTime,
          this.machiaForm.workFinishTime
        );
        // this.machiaForm.workShiftNo = 'BC0019'
        this.showAddDialog = true;
      });
    },

    //修改
    handleUpdata(row) {
      this.type = row.machineType;
      this.opsid = 2;
      this.Matitle = "修改生产作业";
      this.canDisablle = true;
      this.allcanDisablle = false;
      const _data = {
        workTaskID: row.workTaskID,
        workTaskNo: row.workTaskNo,
      };
      this.$api.product.GetProduceCraftWorkTaskDetail(_data).then((res) => {
        this.equipment = res.equipmentDataList;
        this.assisList = res.assistantList;
        this.assisList.forEach((e) => {
          e.employeeCode = e.employeeNo;
        });
        this.machiaForm = res.baseData;
        this.machiaForm.craftState = ''
        this.reasonDataList = res.exceptionReasonList;
        this.machiaForm.exceptionDataList = res.exceptionDataList;
        this.machiaForm.mainMaterialDataList = res.mainMaterialDataList;
        this.machiaForm.ingredientsDataList = res.ingredientsDataList;
        this.machiaForm.pageDetailDataList = res.pageDetailDataList;
        this.machiaForm.exceptionDataList.forEach((item) => {
          item.beginPageNo = Number(item.beginPageNo);
          item.endPageNo = Number(item.endPageNo);
          item.exceptionReason = item.exceptionReason.split(",");
        });
        this.machiaForm.produceUseTime = this.timeFn(
          this.machiaForm.workBeginTime,
          this.machiaForm.workFinishTime
        );
        // this.machiaForm.workShiftNo = 'BC0019'
        console.log(this.machiaForm.workFinishTime);

        this.showAddDialog = true;
      });
    },

    //作废
    handleDone(row) {
      this.$confirm("是否确定作废?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          let obj = {
            workTaskID: row.workTaskID,
            reason: "", //作废原因
          };
          this.$api.system.DisableProduceCraftWorkTask(obj).then((res) => {
            this.$message({
              type: "success",
              message: "作废成功!",
            });
            this.getAllMaterils();
          });
        })
        .catch(() => {});
    },

    //工作效率计算
    efficiency() {
      this.machiaForm.actualWorkTime =
        this.machiaForm.taskUseTime - this.machiaForm.otherUseTime;
      if (this.type == "印刷") {
        if (this.machiaForm.produceMeters && this.machiaForm.actualWorkTime) {
          this.machiaForm.workEfficiency = Math.round(
            (Number(this.machiaForm.produceMeters) /
              Number(this.machiaForm.actualWorkTime)) *
              60
          );
        }
        console.log(this.machiaForm.workEfficiency);
      } else if (this.type == "模切") {
      } else if (this.type == "采集") {
        if (this.machiaForm.productQuantity && this.machiaForm.actualWorkTime) {
          this.machiaForm.workEfficiency = Math.round(
            (Number(this.machiaForm.productQuantity) /
              Number(this.machiaForm.actualWorkTime)) *
              60
          );
        }
      } else if (this.type == "检验") {
        if (this.machiaForm.inspectMeters && this.machiaForm.actualWorkTime) {
          this.machiaForm.workEfficiency = Math.round(
            (Number(this.machiaForm.inspectMeters) /
              Number(this.machiaForm.actualWorkTime)) *
              60
          );
        }
      }
      this.$forceUpdate();
    },

    //副手人员选择事件
    getEmployee(val) {
      //  this.contractForm.contractSigningPerson = val.employeeCode
      // this.contractForm.contractSigningPersonName = val.employeeName

      if (this.assisList.length === 0) {
        this.assisList.push({
          employeeCode: val.employeeCode,
          employeeName: val.employeeName,
        });
      } else {
        const checked = this.assisList.some((item) => {
          if (item.employeeCode === val.employeeCode) {
            return true;
          }
        });
        if (!checked) {
          this.assisList.push({
            employeeCode: val.employeeCode,
            employeeName: val.employeeName,
          });
        }
      }
    },

    deletrPer(index) {
      if (this.allcanDisablle) {
        return;
      } else {
        this.assisList.splice(index, 1);
      }
    },

    openPer() {
      if (this.allcanDisablle) {
        return;
      } else {
        this.isperShow = true;
      }
    },

    getWorkExceptionTypeDataList() {
      this.$api.system.GetWorkExceptionTypeDataList({}).then((res) => {
        this.ExceptionTypeList = res;
      });
    },

    timeFn(d1, d2) {
      if (d1 && d2) {
        // 如果时间格式是正确的，那下面这一步转化时间格式就可以不用了
        const dateBegin = new Date(d1.replace(/-/g, "/")); // 将-转化为/，使用new Date
        const dateEnd = new Date(d2.replace(/-/g, "/")); // 获取当前时间
        const dateDiff = dateEnd.getTime() - dateBegin.getTime(); // 时间差的毫秒数
        const leave1 = dateDiff % (24 * 3600 * 1000); // 计算天数后剩余的毫秒数
        // 计算相差分钟数
        const leave2 = leave1 % (3600 * 1000); // 计算小时数后剩余的毫秒数
        const minutes = Math.floor(leave1 / (60 * 1000)); // 计算相差分钟数
        return minutes;
      }
    },

    addExecp() {
      this.machiaForm.exceptionDataList.push({
        index: this.index,
        beginPageNo: 0,
        endPageNo: 0,
        exceptionNumberSegment: "",
        exceptionType: this.ExceptionTypeList[0].exceptionType,
        exceptionReason: "",
      });
      this.index++;
      console.log(this.machiaForm.exceptionDataList);
    },

    //选择物料
    refuseListsMateriAll(value) {
      value.forEach((item) => {
        this.machiaForm.ingredientsDataList.push(item);
      });
      this.machiaForm.ingredientsDataList = this.unique(
        this.machiaForm.ingredientsDataList
      );
      // this.machiaForm.ingredientsDataList = value
    },

    //添加页码明细
    handleAddPage() {
      this.machiaForm.pageDetailDataList.push({
        index: this.indexPage,
        pageFileName: "",
        totalPageCount: 0,
        beginNo: 0,
        endNo: 0,
        remark: "",
      });
      this.indexPage++;
    },
    //计算
    productMeter() {
      this.machiaForm.productMeters =
        Number(this.machiaForm.scrapMeters) +
        Number(this.machiaForm.finishedMeters);
      this.machiaForm.passCount =
        Number(this.machiaForm.inspectCount) -
        Number(this.machiaForm.noPassCount);
      this.machiaForm.percentDefective =
        (Number(this.machiaForm.noPassCount) /
          Number(this.machiaForm.inspectCount)) *
        100;
    },

    //计算成品米数
    calculation() {
      if (this.type == "丝网") {
        this.machiaForm.workEfficiency = Math.round(
          (Number(this.machiaForm.printCount) /
            Number(this.machiaForm.actualWorkTime)) *
            60
        );
        if (this.machiaForm.printFace && this.machiaForm.printCount) {
          this.machiaForm.sW_ProductMeters =
            (this.machiaForm.printFace * this.machiaForm.printCount) / 1000;
        } else {
          this.machiaForm.sW_ProductMeters = "";
        }
      } else if (this.type == "模切") {
        if (this.machiaForm.knifeVersionSize && this.machiaForm.cutCount) {
          this.machiaForm.mQ_ProductMeters =
            (this.machiaForm.knifeVersionSize * this.machiaForm.cutCount) /
            1000;
        } else {
          this.machiaForm.mQ_ProductMeters = "";
        }
      } else if (this.type == "数码") {
        if (this.machiaForm.printPageCount && this.machiaForm.printPageSize) {
          this.machiaForm.sM_ProductMeters =
            (this.machiaForm.printPageCount * this.machiaForm.printPageSize) /
            1000;
          this.machiaForm.workEfficiency = Math.round(
            (Number(this.machiaForm.sM_ProductMeters) /
              Number(this.machiaForm.actualWorkTime)) *
              60
          );
        } else {
          this.machiaForm.sM_ProductMeters = "";
        }
      } else if (this.type == "检验") {
        if (this.machiaForm.inspectCount && this.machiaForm.noPassCount) {
          this.machiaForm.percentDefective =
            (this.machiaForm.noPassCount / this.machiaForm.inspectCount) * 100;
        } else {
          this.machiaForm.percentDefective = "";
        }
      }
    },

    //完成生产作业
    doneWork(row) {
      this.type = row.machineType;
      this.opsid = 0;
      this.rowID = row.workTaskID;
      this.Matitle = "完成生产作业";
      this.canDisablle = true;
      this.allcanDisablle = false;
      let time = new Date();

      const _data = {
        workTaskID: row.workTaskID,
        workTaskNo: row.workTaskNo,
      };
      this.$api.product.GetProduceCraftWorkTaskDetail(_data).then((res) => {
        this.assisList = res.assistantList;
        this.machiaForm = res.baseData;
        this.machiaForm.craftState = ''
        this.machiaForm.exceptionDataList = res.exceptionDataList;
        this.machiaForm.mainMaterialDataList = res.mainMaterialDataList;
        this.machiaForm.ingredientsDataList = res.ingredientsDataList;
        this.machiaForm.pageDetailDataList = res.pageDetailDataList;
        this.reasonDataList = res.exceptionReasonList;
        this.machiaForm.produceUseTime = this.timeFn(
          this.machiaForm.workBeginTime,
          this.machiaForm.workFinishTime
        );
        // this.machiaForm.workShiftNo = 'BC0019'
        this.machiaForm.workFinishTime = this.dateFtt(
          "yyyy-MM-dd hh:mm:ss",
          time
        );
        var date3 =
          new Date(this.machiaForm.workFinishTime).getTime() -
          new Date(this.machiaForm.workBeginTime).getTime();
        var subMinutes = Math.floor(date3 / (60 * 1000)); //获取总共的分钟差
        this.machiaForm.taskUseTime = subMinutes;
        this.machiaForm.actualWorkTime =
          subMinutes - this.machiaForm.otherUseTime;
        this.showAddDialog = true;
      });
      // this.$confirm("是否确定完成该作业?", "提示", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning",
      // })
      //   .then(() => {
      //     this.saveMachina();
      //   })
      //   .catch(() => {});
    },

    //页码明细选择事件
    handlePageChange(e) {
      this.pageChecked = e;
    },

    //删除页码明细
    handleDeletePage() {
      if (this.pageChecked.length < 1) {
        this.$message.warning("请选择要删除的明细");
      } else {
        this.pageChecked.forEach((j) => {
          if (j.recordID) {
            this.machiaForm.pageDetailDataList =
              this.machiaForm.pageDetailDataList.filter((e) => {
                return e.recordID != j.recordID;
              });
          } else {
            this.machiaForm.pageDetailDataList =
              this.machiaForm.pageDetailDataList.filter((e) => {
                return e.index != j.index;
              });
          }
        });
        this.$forceUpdate();
      }
    },

    //辅料明细选择事件
    handleMaterialChange(e) {
      this.materiaChecked = e;
    },

    //获取班次
    getBC() {
      const _d = {
        isDelete: 0,
        isDisable: 0,
        likeWords: "",
        pageIndex: 1,
        pageSize: 30,
      };

      this.$api.system.GetMatchPageProductClasss(_d).then((res) => {
        this.bcList = res.list;
      });
    },

    //删除辅料明细
    handleDeleteMaterial() {
      if (this.materiaChecked.length < 1) {
        this.$message.warning("请选择要删除的辅料");
      } else {
        this.materiaChecked.forEach((j) => {
          this.machiaForm.ingredientsDataList =
            this.machiaForm.ingredientsDataList.filter((e) => {
              return e.stockGoodsID != j.stockGoodsID;
            });
        });
        this.$forceUpdate();
        console.log(this.machiaForm.ingredientsDataList);
      }
    },

    //异常明细选中事件
    handleAbnormalChange(e) {
      this.abnormalChecked = e;
    },

    //删除异常明细
    handleDeleteAbnormal() {
      if (this.abnormalChecked.length < 1) {
        this.$message.warning("请选择要删除的明细");
      } else {
        this.abnormalChecked.forEach((j) => {
          if (j.exceptionID) {
            this.machiaForm.exceptionDataList =
              this.machiaForm.exceptionDataList.filter((e) => {
                return e.exceptionID != j.exceptionID;
              });
          } else {
            this.machiaForm.exceptionDataList =
              this.machiaForm.exceptionDataList.filter((e) => {
                return e.index != j.index;
              });
          }
        });
        this.$forceUpdate();
      }
    },

    //获取列表
    getAllMaterils() {
      const parmas = this.search;
      this.searchLoading = true;
      this.isShowOption = false;
      this.$api.system
        .GetPageProduceCraftWorkTasksForSacnningWork(parmas)
        .then((res) => {
          this.dataLists = res.list;
          this.isShowOption = true;
          this.dataLists.forEach((item) => {
            for (let i in item) {
              if (item[i] == -1 || (!item[i] && item[i] !== 0)) {
                item[i] = "--";
              }
            }
          });
          this.total = res.totalCount;
          this.searchLoading = false;
        })
        .catch(() => {
          this.searchLoading = false;
          this.isShowOption = true;
        });
    },

    // 获取列表表格表头
    getTableHead() {
      console.log(this.$config.ScanningWorkTabel);
      const parmas = {
        tableCode: this.$config.ScanningWorkTabel,
      };
      this.$api.common.getAllTableHead(parmas).then((res) => {
        res.sort(arraySort("columnSort"));
        this.tableHead = res;
        // 得到客户汇总所有数据列表
        this.getAllMaterils();
        this.calHeight();
        this.$nextTick(() => {
          this.$refs.multipleTable.doLayout();
        });
      });
    },

    // 保存表头样式变化
    saveHead(newArray) {
      const parmas = newArray;
      setTimeout(() => {
        this.$api.common.saveTableStyle(parmas).then(() => {});
      }, 300);
    },
    // 保存表头列宽度
    surverWidth(newWidth, oldWidth, column) {
      setTimeout(() => {
        const heads = [...this.tableHead];
        heads.forEach((item) => {
          if (item.columnCode === column.property) {
            item.columnWidth = column.width;
            return;
          }
        });
        this.saveHead(heads);
      }, 100);
    },
    // 表格最大高度
    calHeight() {
      this.$nextTick(() => {
        const rect = this.$refs.tableCon.getBoundingClientRect();
        this.tableHeight = rect.height;
      });
    },
    // 删除基础数据分组
    deleteMaterielClass(data) {
      const parmas = {
        entityID: data.groupID,
      };
      this.$confirm("确定删除该分组, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$api.mater.DeleteGoodsGroup(parmas).then(() => {
          this.getAllMaterils();
          this.$message({
            message: "删除成功",
            type: "success",
          });
        });
      });
    },
    // 清除所有查询条件
    Refresh() {
      this.search.pageIndex = 1;
      // this.search = this.$options.data().search
      this.getAllMaterils();
    },

    //切换禁用/启用状态
    handleSwich() {
      this.search.pageIndex = 1;
      this.getAllMaterils();
    },

    // 新建弹框关闭事件
    closeDialog() {
      if (this.$refs.materForm) {
        this.$refs.materForm.resetFields();
      }
      this.materForm = this.$options.data().materForm;
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-form--label-top .el-form-item__label {
  padding: 0;
}

::v-deep .dialogInlineForm .el-form-item__content {
  margin-right: 0;
}

.list-item {
  float: left;
  width: 32%;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #e6e6e6;
}

.finish {
  background: #f0f9eb;
  color: #67c23a;
  border-color: #67c23a;
}

.conduct {
  background: #ecf5ff;
  color: #3967ff;
  border-color: #3967ff;
}
.conduct:hover {
  color: #fff;
  background: #3967ff;
}

.head-info {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e6e6e6;
  padding: 0 16px;
}

.item-content {
  margin-top: 8px;
  padding: 16px;
  h1 {
    text-align: center;
    font-size: 26px;
  }
  p {
    text-align: center;
  }
}

.materielList {
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}
.addWuliaoBox {
  padding: 10px 16px;
}

.subTip {
  border-bottom: 1px #e6e6e6 solid;
  background: #f5f6f9;
  padding: 8px 16px;
}

.container {
  height: 100%;
}

.permangeRg {
  border: 1px solid #e6e6e6;
  background: #fff;
  margin-left: 10px;
  height: 100%;
  width: calc(100% - 280px);

  .mainTT {
    font-size: 16px;
    font-weight: bold;
    width: 100%;
    padding: 18px 16px;
    padding-bottom: 0;
  }
}

.permanageLf {
  width: 280px;
  height: 100%;
  border: 1px solid #e6e6e6;
  background: #fff;

  .kuOP {
    display: none;
  }

  li {
    padding: 9px 16px;
    cursor: pointer;

    &:hover {
      background: #3f61f110;
      color: #3f61f1;

      .kuOP {
        display: block !important;
      }
    }
  }

  li.on {
    background: #3f61f110;
    color: #3f61f1;
  }

  .allMateriel {
    line-height: 44px;
    padding-left: 16px;

    &:hover {
      background: #3f61f110;
      color: #3f61f1;
    }
  }

  .allMateriel.crt {
    background: #3f61f110;
    color: #3f61f1;
  }
}

.navTT {
  line-height: 22px;
  padding: 16px;
}

.areasOp {
  li {
    padding: 8px 16px;
    cursor: pointer;

    &:hover {
      background: #f6f6f6;
    }
  }
}

.lNavt {
  padding-right: 4px;
  background: #f7f8fa;

  .itemCon {
    display: flex;
    margin: 10px;
    padding: 0 5px;
    width: 100%;
  }
}

.colorList {
  margin-top: 10px;

  li {
    border: 1px solid #eeeeef;
    margin-bottom: 10px;

    .fName {
      position: relative;

      &:before {
        content: "";
        position: absolute;
        left: 0;
        height: 22px;
        border-left: 3px solid #3f61f1;
        top: -1px;
      }
    }

    .colorCon {
      line-height: 22px;
      padding: 16px;
    }
  }
}

.newLayeeCon {
  margin-top: 10px;

  .el-button {
    width: 100%;
  }
}

.tabCon {
  width: 100%;
  padding: 0 16px;
  .btnlist {
    display: flex;
    justify-content: end;
    padding: 0 16px;
    margin: 16px;
  }
}

.tagsBox {
  display: flex;
  flex: 1;
  height: 100%;
  width: 100%;

  .tagsRgBox {
    width: 320px;
    flex-shrink: 0;
    height: 100%;
    border-left: 1px solid #e6e6e6;
    background: #fff;
    overflow: auto;

    .tabBox {
      ul {
        li {
          width: 33.3%;
          text-align: center;
          height: 32px;
          line-height: 32px;
          border-right: 1px solid #e6e6e6;
          background: #f7f8faff;
          border-bottom: 1px solid #e6e6e6;
          cursor: pointer;

          &:last-child {
            border-right: none;
          }

          &.on {
            background: #fff;
            border-bottom: 1px solid #fff;
          }
        }
      }
    }
  }
}

.permain {
  // align-items: baseline;
  line-height: 40px;
  height: 40px;

  .input {
    width: 100%;
    height: 28px;
    line-height: 28px;
    border-radius: 4px 0 0 4px;
    border: 1px solid #dcdfe6;

    span {
      display: inline-block;
      font-size: 12px;
      height: 22px;
      line-height: 22px;
      padding: 2px 5px;
      background-color: #f5f6f9;
      margin: 2px 5px;
    }
  }

  .bgc57 {
    height: 28px;
    background-color: #f5f7fa;
    border-radius: 0px 4px 4px 0px;
    margin-left: -1px;
  }
}

.cwapper {
  flex: 1;
  flex-direction: column;
  margin-left: 8px;
  .vss {
    height: 100%;
    border: 1px solid #e6e6e6;
    border-radius: 4px;
    overflow: hidden;
  }
}

.infoSCDD {
  background-color: #fff;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  border: 1px solid #e6e6e6;
  padding: 16px;
  margin-bottom: 8px;
  span {
    margin-right: 20px;
    color: #999aaa;
  }
}

.tableCon {
  border: 1px solid #e6e6e6;
}

.cHeader {
  text-align: start;
  font-weight: 600;
  line-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid #e6e6e6;
}

.fleft {
  border-right: 1px solid #d8d8d8;
  padding: 16px;
}

.fright {
  padding: 16px;
  .count {
    display: flex;
    align-items: center;
    color: #999aaa;
  }
  .el-form-item:not(:last-child) {
    margin-bottom: 8px;
  }
}

.subTipBtn {
  border-bottom: 1px #e6e6e6 solid;
  background: #f5f6f9;
  padding: 8px 16px;
}

.cenCon {
  width: 260px;
  height: 100%;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #fff;
  border-right: 1px solid #e6e6e6;

  .itemCenter {
    margin: 10px 0;

    .cenItem {
      margin: 5px 0;
    }

    .carftItem {
      padding: 5px 0;
      font-size: 12px;

      &.active {
        background-color: #f7f8fa;

        .intax {
          background-color: #3f61f1;
          color: #ffffff;
        }

        .name_text {
          color: #3f61f1;
        }
      }

      div {
        margin: 10px;
        font-weight: 400;
        color: #999aaa;
        padding-left: 50px;
      }

      .name {
        padding-left: 0px;

        .name_text {
        }
      }

      .intax {
        display: inline-block;
        background: #f5f6f9;
        border-radius: 2px;
        padding: 5px;
        width: 40px;
        text-align: center;
        margin-right: 10px;
      }
    }
  }

  .addPeoduct {
    cursor: pointer;
    background-color: #3f61f1;
    text-align: center;
    color: #ffffff;
    border-radius: 4px;
    margin: 16px;
    padding: 10px 0;
  }
}

.PBinfo {
  width: 30%;
  margin: 0 10px;
  display: inline-block;
}

.colorPic {
  height: 100%;
  margin: 0 0 5px 0;
  overflow: hidden;

  .img_c {
    width: 250px;
    height: 250px;
    align-items: center;
    justify-content: center;
    display: flex;
    background-color: #e6e6e6;
    margin: 5px 5px;
    // text-align: center;
    position: relative;

    .text {
      position: absolute;
      top: 0;
      left: 0;
      font-size: 12px;
      font-weight: 400;
      color: #ffffff;
      line-height: 22px;
      background: #000000;
      padding: 2px 5px;
      border-radius: 0px 0px 4px 0px;
      opacity: 0.5;
    }

    .yulan {
      width: 24px;
      height: 24px;
      border-radius: 4px;
      position: absolute;
      bottom: 10px;
      right: 16px;
      z-index: 8;
      color: #fff;
      background: #7f7f7f;
    }

    .img_i {
      width: auto;
      height: auto;
      max-width: 100%;
      max-height: 100%;
    }
  }
}

.subTip {
  border-bottom: 1px #e6e6e6 solid;
  background: #f5f6f9;
  padding: 13px 16px;
  margin-bottom: 10px;
}

.formBox {
  padding: 0 16px;

  .order {
    padding: 10px 0;
  }
}

.leftCon {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  width: 320px;
  padding: 0 0 16px;
  border-radius: 4px;
  border: 1px #e6e6e6 solid;
}

.cenright {
  flex: 1;
  background-color: #ffffff;
  height: 100%;
  overflow: auto;

  .zy_add {
    margin: 16px 16px;
  }

  .zy_item {
    background: #ffffff;
    border: 1px solid #eeeeee;
    margin: 0 0 16px;

    .zy_header {
      display: flex;
      align-items: center;
      background: #f5f6f9;
      padding: 5px 5px 5px 16px;

      span {
        margin-right: 20px;
        color: #999aaa;
      }
    }

    .zy_info {
      padding: 16px;
      display: flex;
      flex-wrap: wrap;
      color: #999aaa;
      .divt {
        width: 33%;
        margin: 8px 0;
      }

      .cot {
        width: 100%;
      }

      .bigdialogTbCon {
        width: 100%;
        border: 1px solid #eeeeee;

        .ht {
          line-height: 44px;
          width: 100%;
          background: #f7f8fa;
          margin: 0;
          padding: 0 16px;

          span {
            font-weight: 600;
            color: #333333;
          }
        }
      }
    }
  }
}

.orderForm {
  height: calc(100%);
  width: 100%;
}

.mainCenter {
  height: calc(100% - 52px);
  width: 100%;
  overflow-x: hidden;
  padding: 8px;
}

.container {
  height: 100%;
  width: 100%;
}

.tagCon {
  width: 100%;
  flex: 1;
  overflow-x: hidden;
  margin: 0px 0 0 10px;
  background-color: #ffffff;

  .cginfo {
    margin: 0 16px;
  }

  .selectCon {
    line-height: 44px;
    text-align: center;
    background: #ffffff;
    border-radius: 4px 4px 0px 0px;
    border: 1px solid #e6e6e6;

    span {
      display: inline-block;
      margin: 0 32px;
      font-size: 16px;
      line-height: 44px;
      font-weight: 600;
      color: #333333;
      cursor: pointer;

      &.select {
        color: #3f61f1;
        border-bottom: 2px solid #3f61f1;
      }
    }
  }

  .tagList {
    box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.05);
    border: 1px solid #e6e6e6;
    margin: 16px;

    .listNav {
      height: 44px;
      padding: 0 14px;
      background: #f5f6f9;
      border-bottom: 1px solid #e6e6e6;
    }

    .tagShow {
      background-color: #ffffff;
      border: 1px solid #e4e7ed;

      .tagBaseList {
        padding: 14px;
        padding-bottom: 8px;

        li {
          line-height: 24px;
          width: 50%;
          margin: 5px 0;
        }

        .titles {
          width: 100px;
        }
      }

      .layerTable {
        padding: 16px;
        padding-top: 0;

        .border {
          border: solid #ebeef5;
          border-width: 0 1px 0 1px;
        }
      }
    }
  }
}

.orderRemark {
  line-height: 24px;
  padding-bottom: 16px;
}

.orderContent {
  flex: 1;
}

.drgCard {
  background: #ffffff;
  border-radius: 4px;
  border: 1px solid #eeeeee;
  padding: 5px 0;
  text-align: center;
  // line-height: 44px;
  align-items: center;

  .line_div {
    width: 120px;

    &.w15 {
      width: 15%;
    }

    &.w10 {
      width: 80px;
    }

    &.mlr10 {
      margin: 0 10px 0 0;
    }
  }
}

.tableBox {
  margin-top: 10px;
  overflow: hidden;
  border: 1px #e6e6e6 solid;
  border-bottom: none;
  .bigdialogTable {
    span {
      display: inline-block;
      text-align: center;
      font-weight: bold;
      width: 120px;
      &.w15 {
        width: 15%;
      }

      &.w10 {
        width: 10%;
      }
    }
  }

  .tt {
    height: 38px;
    line-height: 38px;
    background: #f7f8fa;
    padding-left: 16px;
  }

  .title {
    border-radius: 0;
    border: 1px solid #e6e6e6;
  }
}

::v-deep .formItem {
  .el-form-item {
    margin-bottom: 0;
    color: #999aaa;
  }

  .min_item .el-form-item__label {
    line-height: 28px;
    color: #999aaa;
  }

  .min_item .el-form-item__content {
    line-height: 28px;
  }

  .el-form-item__label {
    line-height: 28px;
    color: #999aaa;
  }

  .el-form-item__content {
    line-height: 28px;
    height: 28px;
    color: #333;

    .el-input-group {
      vertical-align: initial;
      margin-top: 0;
    }
  }

  .el-select,
  .el-date-editor.el-input {
    width: 100%;
  }

  .el-textarea {
    vertical-align: middle;
  }
}
</style>
<style lang="scss">
.el-loading-mask {
  top: 0;
}

.operations {
  display: flex;
  align-items: center;
}
.operations i {
  padding-right: 5px;
}

.operations > span:first-child {
  padding-right: 5px;
}

.operations > span {
  font-weight: 400;
  color: #000;
  cursor: pointer;
}

.operations > span:last-child {
  padding-left: 5px;
}

.d_treeBox {
  margin-right: 0 !important;
  border-radius: 10px 0 0 10px;
  border-right: none !important;
}

.d_main {
  border-radius: 0 10px 10px 0;
}
</style>
